package com.chenwc.serialassistant.threadpool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 拒绝策略
 *
 * @author wxhntmy
 */
public class MyIgnorePolicy implements RejectedExecutionHandler {

    private final static Logger logger = LoggerFactory.getLogger(MyIgnorePolicy.class);

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
        doLog(r, e);
    }

    private void doLog(Runnable r, ThreadPoolExecutor e) {
        // 可做日志记录等
        logger.info("{} 线程已拒绝！", r.toString());
    }
}
